cssprovider: Use g_type_depth() instead of computing the depth manually
authorBenjamin Otte <otte@redhat.com>
Fri, 1 Apr 2011 22:03:18 +0000 (00:03 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 14 Apr 2011 12:59:24 +0000 (14:59 +0200)
gtk/gtkcssprovider.c

index facac8a5bcc4cca8f631f0a589298d29d776a957..a9331575f97c76269c355f76008ce4b050b6401d 100644 (file)
@@ -1138,23 +1138,15 @@ compare_selector_element (GtkWidgetPath   *path,
         *score |= 0xF;
       else
         {
-          GType parent = type;
+          guint diff = g_type_depth (type) - g_type_depth (elem->type);
 
-          *score = 0xE;
-
-          while ((parent = g_type_parent (parent)) != G_TYPE_INVALID)
+          if (G_UNLIKELY (diff > 0xE))
             {
-              if (parent == elem->type)
-                break;
-
-              *score -= 1;
-
-              if (*score == 1)
-                {
-                  g_warning ("Hierarchy is higher than expected.");
-                  break;
-                }
+              g_warning ("Hierarchy is higher than expected.");
+              diff = 0xE;
             }
+          
+          *score = 0XF - diff;
         }
 
       return TRUE;